/*
* AirGasController.java
* Created on  202015/6/24 11:43
* �汾       �޸�ʱ��          ����      �޸�����
* V1.0.1    202015/6/24       longshihui    ��ʼ�汾
*
*/

package com.infitecs.eyas.boiler;

import com.infitecs.eyas.boiler.dao.AirGasParameterDao;
import com.infitecs.eyas.boiler.model.AirGasParameter;
import com.infitecs.eyas.boiler.model.SodaParameter;
import com.infitecs.eyas.boiler.service.AirGasParameterService;
import com.infitecs.eyas.nature.dao.NatureDao;
import com.infitecs.eyas.nature.model.Nature;
import com.infitecs.eyas.quality.dao.ElementDao;
import com.infitecs.eyas.quality.model.Element;
import com.infitecs.eyas.result.service.MiddleResultService;

import com.infitecs.eyas.util.DoubleUtil;
import com.infitecs.krill.ajax.response.AjaxResponse;
import com.infitecs.krill.ajax.response.ReturnState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * ���������Ϣ
 *
 * @author longshihui
 * @version 1.0.1
 */
@Controller
@RequestMapping("/boiler/airGas/")
public class AirGasController {
    @Autowired
    MiddleResultService middleResultService;
    @Autowired
    AirGasParameterService airGasParameterService;
    @Autowired
    private AirGasParameterDao airGasParameterDao;
    @Autowired
    private ElementDao elementDao;
    
    @RequestMapping(value = "calculateE49", method = RequestMethod.POST)
    @ResponseBody
    public double calculateE49(AirGasParameter air) {
        Element element = elementDao.getElementByPowerCaseId(air.getPowerCaseId());
        double e47 = airGasParameterService.calculateE47(element);
        double e48 = airGasParameterService.calculateE48(e47);
        double e49 = airGasParameterService.calculateE49(air, e48);
        return DoubleUtil.getInstance().get2Double(e49);
    }

    @RequestMapping(value="saveTheValueOfE31",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE31(@RequestParam("E31")double E31,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE31(E31,caseId);
    }

    @RequestMapping(value="saveTheValueOfE32",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE32(@RequestParam("E32")double E32,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE32(E32,caseId);
    }

    @RequestMapping(value="saveTheValueOfE33",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE33(@RequestParam("E33")double E33,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE33(E33,caseId);
    }

    @RequestMapping(value="saveTheValueOfE34",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE34(@RequestParam("E34")double E34,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE34(E34,caseId);
    }

    @RequestMapping(value="saveTheValueOfE35",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE35(@RequestParam("E35")double E35,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE35(E35,caseId);
    }

    @RequestMapping(value="saveTheValueOfE28",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE28(@RequestParam("E28")double E28,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE28(E28,caseId);
    }

    @RequestMapping(value="saveTheValueOfE42",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE42(@RequestParam("E42")double E42,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE42(E42,caseId);
    }

    @RequestMapping(value="saveTheValueOfE43",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE43(@RequestParam("E43")double E43,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE43(E43,caseId);
    }

    @RequestMapping(value="saveTheValueOfE44",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE44(@RequestParam("E44")double E44,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE44(E44,caseId);
    }

    @RequestMapping(value="saveTheValueOfE45",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE45(@RequestParam("E45")double E45,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE45(E45,caseId);
    }

    @RequestMapping(value="saveTheValueOfE46",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE46(@RequestParam("E46")double E46,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE46(E46,caseId);
    }

    @RequestMapping(value="saveTheValueOfE111",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE111(@RequestParam("E111")int E111,HttpSession httpSession){
        int caseId=Integer.parseInt(httpSession.getAttribute("caseId").toString());
        airGasParameterService.saveTheValueOfE111(E111,caseId);
    }

    @RequestMapping(value="saveTheValueOfE50",method={RequestMethod.POST})
    @ResponseBody
    public void saveTheValueOfE50(@RequestParam("E50")double E50,HttpSession httpSession){
        int caseId = Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        airGasParameterService.saveTheValueOfE50(E50,caseId);
    }

    @RequestMapping(value ="calculateE36",method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResponse calculateE36(HttpSession httpSession){
        int caseId =Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        String E36=String.valueOf(airGasParameterService.calculateE36(caseId,powerId));
        return new AjaxResponse(E36);
    }
    @RequestMapping(value ="calculateE37",method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResponse calculateE37(HttpSession httpSession){
        int caseId =Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        String E37=String.valueOf(airGasParameterService.calculateE37(caseId, powerId));
        return new AjaxResponse(E37);
    }
    @RequestMapping(value ="calculateE38",method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResponse calculateE38(HttpSession httpSession){
        int caseId =Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        String E38=String.valueOf(airGasParameterService.calculateE38(caseId, powerId));
        return new AjaxResponse(E38);
    }
    @RequestMapping(value ="calculateE39",method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResponse calculateE39(HttpSession httpSession){
        int caseId =Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        String E39=String.valueOf(airGasParameterService.calculateE39(caseId, powerId));
        return new AjaxResponse(E39);
    }
    @RequestMapping(value ="calculateE40",method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResponse calculateE40(HttpSession httpSession){
        int caseId =Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        String E40=String.valueOf(airGasParameterService.calculateE40(caseId,powerId));
        return new AjaxResponse(E40);
    }
    @RequestMapping(value ="calculateE41",method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResponse calculateE41(HttpSession httpSession){
        int caseId =Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        String E41=String.valueOf(airGasParameterService.calculateE41(caseId,powerId));
        return new AjaxResponse(E41);
    }
    @RequestMapping(value ="calculateE61",method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResponse calculateE61(HttpSession httpSession){
        int caseId =Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        String E61=String.valueOf(airGasParameterService.calculateE61(caseId, powerId));
        return new AjaxResponse(E61);
    }
    @RequestMapping(value ="calculateE63",method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResponse calculateE63(HttpSession httpSession){
        int caseId =Integer.parseInt(httpSession.getAttribute("caseId").toString());
        int powerId=Integer.parseInt(httpSession.getAttribute("powerId").toString());
        String E63= String.valueOf(airGasParameterService.calculateE63(caseId,powerId));
        return new AjaxResponse(E63);
    }

    @RequestMapping(value = "airGasSave", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResponse airGasSave(AirGasParameter airGasParameter) {
        try {
            airGasParameterService.airGasSave(airGasParameter);
            return new AjaxResponse();
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResponse(ReturnState.ERROR, "请检查填写数据是否有误，操作失败");
        }
    }
}
